package com.xh.sso.server.controller;

import com.xh.security.core.authentiation.oauth2.support.config.AuthConfig;
import com.xh.security.core.authentiation.oauth2.support.model.AuthCallback;
import com.xh.security.core.authentiation.oauth2.support.request.AuthRequest;
import com.xh.sso.server.authentiation.oauth2.support.request.AuthSsoRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Name AuthController
 * @Description
 * @Author wen
 * @Date 2020-04-25
 */
@Controller
public class AuthController {


    @GetMapping("/login")
    public String login() {
        return "login";
    }

    @GetMapping("/index")
    public String index() {
        return "index";
    }

    @GetMapping("/oauth/callback")
    @ResponseBody
    public Object callback(AuthCallback callback){
        return new AuthSsoRequest(AuthConfig.builder()
                .clientId("ht17520")
                .clientSecret("ht17520")
                .redirectUri("http://localhost:9999/auth/oauth/callback")
                .build(), null).getAccessToken(callback);
    }

}
